package utils

var (
	close_event_queue   []func()
	startup_event_queue []func() bool
)

func AppendCloseEvent(fn func()) {
	close_event_queue = append(close_event_queue, fn)
}

func AppendStartupEvent(fn func() bool) {
	startup_event_queue = append(startup_event_queue, fn)
}

func DoAppClose() {
	for i := 0; i < len(close_event_queue); i++ {
		close_event_queue[i]()
	}
}

func DoAppStartup() bool {
	for i := 0; i < len(startup_event_queue); i++ {
		if !startup_event_queue[i]() {
			return false
		}
	}

	return true
}
